#include "clkMath.h"

int randI()
{
	return rand();
}

int randI(int min, int max)
{
	return (rand()%(max-min))+min;
}

float randF()
{
	return ((float)rand())/((float)RAND_MAX);
}

float randF(float min, float max)
{
	return min+((float)rand())/(((float)RAND_MAX)/(max-min));
}

float polarAngle(V2DF c)
{
	return atan2(c.y,c.x);
}

float polarAngleXY(V3DF c)
{
	return atan2(c.y,c.x);
}

float polarAngleXZ(V3DF c)
{
	return atan2(c.x,c.z);
}

V2DF nrCrPoint(V2DF c, float r, V2DF p)
{
	V2DF cp = p-c;
	float len = cp.magnitude();
	V2DF proj = (cp*1.0f/len)*r;
	return c+proj;
}

bool pointInAABB(V2DF pnt, V2DF min, V2DF max)
{
	if(pnt.x < min.x ||
		pnt.x > max.x ||
		pnt.y < min.y ||
		pnt.y > max.y)
		return false;
	return true;
}

bool C2COverlap(V2DF cA, float rA, V2DF cB, float rB)
{
	if(cA.distance(cB) < rA+rB)
		return true;
	return false;
}